<template>
  <div id="contsainer"></div>
</template>
<script>
export default {
  data() {
    return {
      viewer: null
    }
  },
  mounted() {
    this.initCesium()
    this.addPolylineMaterialAppearance(this.viewer)
  },
  methods: {
    initCesium() {
      this.viewer = new Cesium.Viewer('contsainer', {
        animation: false,
        baseLayerPicker: false,
        fullscreenButton: false,
        geocoder: false,
        homeButton: false,
        infoBox: false,
        sceneModePicker: false,
        navigationHelpButton: false,
        scene3DOnly: true,
        timeline: false,
        selectionIndicator: false, //是否显示选取指示器组件
        shouldAnimate: false, //自动播放动画控件
        shadows: true, //是否显示光照投射的阴影
        terrainShadows: Cesium.ShadowMode.RECEIVE_ONLY, //地质接收阴影
        sceneMode: Cesium.SceneMode.SCENE3D
      })
      this.viewer._cesiumWidget._creditContainer.style.display = 'none' //	去除版权信息
    },
    addPolylineMaterialAppearance(viewer) {
    let  positions = []
      for (let i = 0 ; i < 40 ; i++){
        positions.push(Cesium.Cartesian3.fromDegrees(-100 + i,48))
      }
      let poliline = new Cesium.PolylineGeometry({
        positions:positions,
        width:10,
        vertexFormat:Cesium.PolylineMaterialAppearance.VERTEX_FORMAT
      })
      let geometry = Cesium.PolylineGeometry.createGeometry(poliline)

      let polylineInstance1 = new Cesium.GeometryInstance({
        geometry:geometry,
        id:'polylineInstance1'
      })

        let primitive = new Cesium.Primitive({
        geometryInstances:[polylineInstance1],
        asynchronous:false,// 是否采用多线程
        appearance:new Cesium.PolylineMaterialAppearance({
          translucent:false, // 半透明
          flat:true, // 当为true时 片段着色器中将使用平面阴影 这意味着不考虑光照
          material:Cesium.Material.fromType(Cesium.Material.PolylineGlowType)

        })
      })
      viewer.scene.primitives.add(primitive)




      // console.log('33', viewer)
    }


  }
}
</script>
<style scoped>
#contsainer {
  height: 100%;
  width: 100%;
  background-color: red;
}
</style>
